/*
Copyright 2025 PerfXLab (Beijing) Technologies Co., Ltd.

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

    http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
#include "OpenSparseBLAS_func.h"
#include "OpenSparseBLAS_type.h"
#include "OpenSpB_Global.h"
#include "OpenSpB_Error.h"

OpenSpB_info OpenSpB_Global_Option_set_ext // set a global default option
    (
        OpenSpB_option_field_ext field,  // option to change
        OpenSpB_object_format_ext format // value to change it to
    )
{
    switch (field)
    {
    case OpenSpB_matrix_format:
    {
        if (!(format.matrix_format == OpenSpB_csc ||
              format.matrix_format == OpenSpB_csr))
        {
            return OpenSpB_failure;
        }
        OpenSpB_Global_is_csc_set(format.matrix_format != OpenSpB_csr);
        break;
    }
    case OpenSpB_vector_format:
    {
        OpenSpB_Global_Vector_Format_set(format.vector_format);
        break;
    }
    default:
        OpenSpB_Error("Unknown global option!\n \
(Maybe it has not been implemented!)\n",
                  __FILE__, __LINE__);
        break;
    }

    return OpenSpB_success;
}